#include <iostream>
using namespace std;

#include <conio.h>
#include "Console.h"
using namespace Course;

#include "game.h"
#include "highScore.h"

int main(){
	int cursorpos = 0;
	int input;
	game g1;
	highScore h;

	while (true){
		system("cls");
		Console::gotoxy(2, 2);
		g1.textClr('y');
		cout << "BLACK JACK";
		g1.textClr();

		Console::gotoxy(2, 10);
		cout << "New Game";
		Console::gotoxy(2, 11);
		cout << "High Score";
		Console::gotoxy(2, 12);
		cout << "Quit";
		switch (cursorpos){
		case 0:
			Console::gotoxy(0, 10);
			cout << "=>";
			Console::gotoxy(0, 11);
			cout << "  ";
			Console::gotoxy(0, 12);
			cout << "  ";
			break;
		case 1:
			Console::gotoxy(0, 10);
			cout << "  ";
			Console::gotoxy(0, 11);
			cout << "=>";
			Console::gotoxy(0, 12);
			cout << "  ";
			break;
		case 2:
			Console::gotoxy(0, 10);
			cout << "  ";
			Console::gotoxy(0, 11);
			cout << "  ";
			Console::gotoxy(0, 12);
			cout << "=>";
		default:
			break;
		}
		input = _getch();
		switch (input){
		case 80:
			if (cursorpos < 2)
				cursorpos++;
			break;
		case 72:
			if (cursorpos > 0)
				cursorpos--;
			break;
		case 13:
			switch (cursorpos){
			case 0:
				g1.run();
				h.read();
				h.add(g1.getName(), g1.getScore());
				h.write();
				break;
			case 1:
				h.display();
				system("cls");
				break;
			case 2:
				return 0;
			default:
				break;
			}
		default:
			break;
		}		
	}
}